home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / darfuncs.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  30.0 KB  |  680 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import AuxFuncs
  6. import EnemyTypes
  7. import Sparks
  8. import Actions
  9. import math
  10. import Breakings
  11. import types
  12. import Reference
  13. import Blood
  14. import SolidMask
  15. import ObjStore
  16. import GameStateAux
  17. import os
  18. import Blood
  19. import ItemTypes
  20. ActualLevel = Bladex.GetCurrentMap()
  21.  
  22. def Cafin(entity_name, camera_element, node):
  23.     cam = Bladex.GetEntity('Camera')
  24.     if node == 1:
  25.         cam.SType = 0
  26.         cam.ETarget = 'Player1'
  27.         cam.TType = 2
  28.         cam.CameraClearPath(0)
  29.         cam.CameraClearPath(1)
  30.     
  31.  
  32.  
  33. def BackPlayer():
  34.     Cam = Bladex.GetEntity('Camera')
  35.     Cam.SetPersonView('Player1')
  36.  
  37.  
  38. def ChangePointOfView(ox2, oy2, oz2, time, person = 'Player1'):
  39.     cam = Bladex.GetEntity('Camera')
  40.     ox1 = cam.Position[0]
  41.     oy1 = cam.Position[1]
  42.     oz1 = cam.Position[2]
  43.     cam.AddCameraNode(0, time, ox1, oy1, oz1)
  44.     cam.AddCameraNode(0, time / 2.0, ox2, oy2, oz2)
  45.     cam.AddCameraNode(0, time / 2.0, (ox1 + ox2) / 2.0, (oy1 + oy2) / 2.0, (oz1 + oz2) / 2.0)
  46.     cam.ETarget = person
  47.     cam.TType = 2
  48.     cam.SType = 1
  49.     cam.CameraStartPath(0)
  50.     cam.ChangeNodeFunc = Cafin
  51.  
  52.  
  53. def ChangeCam(ox2, oy2, oz2, tx2, ty2, tz2, time, CafinProx):
  54.     cam = Bladex.GetEntity('Camera')
  55.     ox1 = cam.Position[0]
  56.     oy1 = cam.Position[1]
  57.     oz1 = cam.Position[2]
  58.     tx1 = cam.TPos[0]
  59.     ty1 = cam.TPos[1]
  60.     tz1 = cam.TPos[2]
  61.     cam.AddCameraNode(0, time, ox1, oy1, oz1)
  62.     cam.AddCameraNode(0, time / 2.0, ox2, oy2, oz2)
  63.     cam.AddCameraNode(0, time / 2.0, (ox1 + ox2) / 2.0, (oy1 + oy2) / 2.0, (oz1 + oz2) / 2.0)
  64.     cam.AddCameraNode(1, time, tx1, ty1, tz1)
  65.     cam.AddCameraNode(1, time / 2.0, tx2, ty2, tz2)
  66.     cam.AddCameraNode(1, time / 2.0, (tx1 + tx2) / 2.0, (ty1 + ty2) / 2.0, (tz1 + tz2) / 2.0)
  67.     cam.ETarget = 'Player1'
  68.     cam.SType = 1
  69.     cam.TType = 1
  70.     cam.CameraStartPath(0)
  71.     cam.ChangeNodeFunc = CafinProx
  72.  
  73.  
  74. def InitGiroCamera():
  75.     cam = Bladex.GetEntity('Camera')
  76.     VecRot = (2 * cam.TPos[0] - cam.Position[0], 2 * cam.TPos[1] - cam.Position[1], 2 * cam.TPos[2] - cam.Position[2])
  77.     cam.ESource = 'Player1'
  78.     cam.SType = 2
  79.     cam.TType = 0
  80.     cam.TPos = VecRot
  81.  
  82.  
  83. def GiraCamara(AngleVariation):
  84.     cam = Bladex.GetEntity('Camera')
  85.     VecRot = (cam.TPos[0] - cam.Position[0], cam.TPos[1] - cam.Position[1], cam.TPos[2] - cam.Position[2])
  86.     vtpos = (VecRot[0] * math.cos(AngleVariation) - VecRot[2] * math.sin(AngleVariation), VecRot[0], VecRot[0] * math.sin(AngleVariation) + VecRot[2] * math.cos(AngleVariation))
  87.     cam.TPos = (vtpos[0] + cam.Position[0], cam.TPos[1], vtpos[2] + cam.Position[2])
  88.  
  89. DeathState = 0
  90. DeathFile = None
  91.  
  92. def DetieneArmaMuerto(obj_name):
  93.     if DeathFile:
  94.         o = Bladex.GetEntity(obj_name)
  95.         o.OnStopFunc = None
  96.         DeathFile.write("o = Bladex.CreateEntity('" + obj_name + "','" + o.Kind + "'," + str(o.Position[0]) + ',' + str(o.Position[1]) + ',' + str(o.Position[2]) + ",'Weapon')\n")
  97.         DeathFile.write('o.Orientation = ' + str(o.Orientation[0]) + ',' + str(o.Orientation[1]) + ',' + str(o.Orientation[2]) + ',' + str(o.Orientation[3]) + '\n')
  98.         DeathFile.write('ItemTypes.ItemDefaultFuncs(o)\n\n')
  99.     
  100.  
  101.  
  102. def DetieneMutilacion(obj_name):
  103.     if DeathFile:
  104.         o = Bladex.GetEntity(obj_name)
  105.         o.OnStopFunc = None
  106.         DeathFile.write('\no = ' + o.Data[0] + '.SeverLimb(' + str(o.Data[1]) + ')\n')
  107.         DeathFile.write('o.Stop()\n')
  108.         DeathFile.write('o.Position    = ' + str(o.Position[0]) + ',' + str(o.Position[1]) + ',' + str(o.Position[2]) + '\n')
  109.         DeathFile.write('o.Orientation = ' + str(o.Orientation[0]) + ',' + str(o.Orientation[1]) + ',' + str(o.Orientation[2]) + ',' + str(o.Orientation[3]) + '\n')
  110.     
  111.  
  112.  
  113. def GrabarLaSangre(x, y, z):
  114.     if DeathFile:
  115.         DeathFile.write("Bladex.CreateEntity('BloodPool','Entity Pool'," + str(x) + ',' + str(y) + ',' + str(z) + ')\n')
  116.     
  117.  
  118.  
  119. def CloseDeathFile():
  120.     global DeathFile
  121.     if DeathFile:
  122.         print "closing 'death.py'..."
  123.         DeathFile.close()
  124.         DeathFile = None
  125.         os.rename('pak/deaths.py_', 'pak/deaths.py')
  126.         Blood.AfterCreateBlood = None
  127.     
  128.  
  129.  
  130. def MuertoyTroceado2(name, trozos):
  131.     muertoint2 = Bladex.GetEntity(name)
  132.     muertoint2.CastShadows = 0
  133.     muertoint2.SetOnFloor()
  134.     muertoint2.Life = 0
  135.     for i in trozos:
  136.         mut = muertoint2.SeverLimb(i)
  137.     
  138.  
  139. muertonum = 0
  140.  
  141. def MuertoyTroceado(x, y, z, raze, weapon, trozos, angul = 2.19288423389, MeshName = None):
  142.     global DeathState, DeathFile, muertonum
  143.     if DeathState:
  144.         return None
  145.     
  146.     if not DeathFile:
  147.         if 'deaths.py' in os.listdir('./pak/'):
  148.             execfile('pak/deaths.py')
  149.             DeathState = 1
  150.             return None
  151.         
  152.         print "Creating 'deaths.py'..."
  153.         DeathFile = open('pak/deaths.py_', 'w')
  154.         DeathFile.write('import Bladex\nimport ItemTypes \n\n')
  155.         DeathFile.write("print 'loading deaths...'\n\n\n")
  156.         Blood.AfterCreateBlood = GrabarLaSangre
  157.     
  158.     if weapon != '':
  159.         armamuertoint2 = Bladex.CreateEntity(ActualLevel + 'WeapDeath' + `muertonum`, weapon, 0, 0, 0, 'Weapon')
  160.         ItemTypes.ItemDefaultFuncs(armamuertoint2)
  161.         armamuertoint2.OnStopFunc = DetieneArmaMuerto
  162.     
  163.     muertoint2 = Bladex.CreateEntity(ActualLevel + 'GuyInPieces' + `muertonum`, raze, x, y, z, 'Person')
  164.     if MeshName:
  165.         muertoint2.SetMesh(MeshName)
  166.     
  167.     muertoint2.Angle = angul
  168.     if weapon != '':
  169.         Actions.TakeObject(muertoint2.Name, armamuertoint2.Name)
  170.         print 'The guy ', muertoint2.Name, ' got a gun named ', armamuertoint2.Name
  171.     else:
  172.         print 'The guy ', muertoint2.Name, 'is armless'
  173.     EnemyTypes.EnemyDefaultFuncs(muertoint2)
  174.     MuertoyTroceado2(muertoint2.Name, trozos)
  175.     DeathFile.write(muertoint2.Name + ' = ' + "Bladex.CreateEntity('" + muertoint2.Name + "','" + muertoint2.Kind + "'," + str(muertoint2.Position[0]) + ',' + str(muertoint2.Position[1]) + ',' + str(muertoint2.Position[2]) + ",'Person'")
  176.     if MeshName:
  177.         DeathFile.write(",'" + MeshName + "')\n\n")
  178.     else:
  179.         DeathFile.write(')\n\n')
  180.     DeathFile.write(muertoint2.Name + '.Angle = ' + str(angul) + '\n')
  181.     DeathFile.write(muertoint2.Name + '.Life = 0\n')
  182.     DeathFile.write(muertoint2.Name + '.SetOnFloor()\n\n')
  183.     Bladex.AddScheduledFunc(Bladex.GetTime() + 60.0, CloseDeathFile, ())
  184.     muertonum = muertonum + 1
  185.  
  186.  
  187. def Let_temblOff():
  188.     cam = Bladex.GetEntity('Camera')
  189.     cam.EarthQuakeFactor = 0
  190.     cam.EarthQuake = 0
  191.  
  192.  
  193. def Temblores(time, pianoforte = 500):
  194.     cam = Bladex.GetEntity('Camera')
  195.     cam.EarthQuakeFactor = pianoforte
  196.     cam.EarthQuake = 1
  197.     Bladex.AddScheduledFunc(Bladex.GetTime() + time, Let_temblOff, ())
  198.  
  199.  
  200. def DetenLaCamaraDeLaConchaELaLora(Camera, frame):
  201.     import Scorer
  202.     cam = Bladex.GetEntity('Camera')
  203.     cam.SetPersonView('Player1')
  204.     cam.Cut()
  205.     Bladex.ActivateInput()
  206.     Scorer.SetVisible(1)
  207.     Bladex.SetListenerPosition(1)
  208.  
  209.  
  210. def LaunchMaxCamera(CamName, Start, End, Funchi = DetenLaCamaraDeLaConchaELaLora):
  211.     import Scorer
  212.     cam = Bladex.GetEntity('Camera')
  213.     cam.SetMaxCamera(CamName, Start, End)
  214.     Scorer.SetVisible(0)
  215.     Bladex.SetListenerPosition(2)
  216.     Bladex.DeactivateInput()
  217.     cam.AddCameraEvent(-1, Funchi)
  218.  
  219.  
  220. def HideObject(oname):
  221.     pass
  222.  
  223.  
  224. def UnhideObject(oname):
  225.     pass
  226.  
  227.  
  228. def HideBadGuy(name, ciego = 1, sordo = 1):
  229.     pers = Bladex.GetEntity(name)
  230.     if not pers:
  231.         print 'WARNING : Trying to hide `' + name + '`but was deleted !'
  232.         return None
  233.     
  234.     pers.Deaf = sordo
  235.     pers.Blind = ciego
  236.     pers.Freeze()
  237.     pers.RemoveFromWorld()
  238.     HideObject(pers.InvLeft)
  239.     HideObject(pers.InvRight)
  240.     HideObject(pers.InvRightBack)
  241.     HideObject(pers.InvLeftBack)
  242.     HideObject(pers.InvLeft2)
  243.     char = Bladex.GetEntity('Player1')
  244.     if char.ActiveEnemy == name:
  245.         char.SetActiveEnemy('')
  246.     
  247.  
  248.  
  249. def UnhideBadGuy(name):
  250.     pers = Bladex.GetEntity(name)
  251.     pers.Deaf = 0
  252.     pers.Blind = 0
  253.     pers.UnFreeze()
  254.     pers.PutToWorld()
  255.     UnhideObject(pers.InvLeft)
  256.     UnhideObject(pers.InvRight)
  257.     UnhideObject(pers.InvRightBack)
  258.     UnhideObject(pers.InvLeftBack)
  259.     UnhideObject(pers.InvLeft2)
  260.  
  261.  
  262. def OnUse(entity, onuse):
  263.     import GameText
  264.     GameText.WriteText(Bladex.GetEntity(entity).Data.MessageHint)
  265.  
  266.  
  267. class EmptyClass:
  268.     pass
  269.  
  270.  
  271. def SetHint(gp, Name, OnUseData = '', Priority = 8.0, Distance = 4000.0):
  272.     import MenuText
  273.     Reference.EntitiesSelectionData[gp.Name] = (Priority, Distance, MenuText.GetMenuText(Name))
  274.     if type(OnUseData) == type(''):
  275.         if OnUseData != '':
  276.             gp.UseFunc = OnUse
  277.             if not (gp.Data):
  278.                 gp.Data = EmptyClass()
  279.             
  280.             gp.Data.MessageHint = OnUseData
  281.         
  282.     else:
  283.         gp.UseFunc = OnUseData
  284.  
  285. QuakeFactor = 100
  286.  
  287. def QuakeStep(personaje):
  288.     cam = Bladex.GetEntity('Camera')
  289.     cam.EarthQuakeFactor = QuakeFactor
  290.     cam.EarthQuake = 1
  291.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.125, QuakeHalf, ())
  292.  
  293.  
  294. def QuakeHalf():
  295.     QuakeStepCounter = 1
  296.     cam = Bladex.GetEntity('Camera')
  297.     cam.EarthQuakeFactor = cam.EarthQuakeFactor / 2
  298.     Bladex.AddScheduledFunc(Bladex.GetTime() + 0.125, QuakeStop, ())
  299.  
  300.  
  301. def QuakeStop():
  302.     QuakeStepCounter = 2
  303.     cam = Bladex.GetEntity('Camera')
  304.     cam.EarthQuakeFactor = 0
  305.     cam.EarthQuake = 0
  306.  
  307. FIRE_DAMAGE = 1
  308.  
  309. def QuemaTimer(e_name, time):
  310.     char = Bladex.GetEntity(e_name)
  311.     char.Life = char.Life - FIRE_DAMAGE
  312.     if char.Life <= 0:
  313.         Actions.FireDeath(e_name)
  314.         char.RemoveFromList('Timer15')
  315.         char.TimerFunc = ''
  316.     
  317.  
  318.  
  319. def EntraQuema(triggername, entityname):
  320.     if entityname == 'Player1':
  321.         char = Bladex.GetEntity('Player1')
  322.         char.SubscribeToList('Timer15')
  323.         char.TimerFunc = QuemaTimer
  324.     
  325.  
  326.  
  327. def SaleQuema(triggername, entityname):
  328.     if entityname == 'Player1':
  329.         char = Bladex.GetEntity('Player1')
  330.         char.RemoveFromList('Timer15')
  331.         char.TimerFunc = ''
  332.     
  333.  
  334.  
  335. def FireOnGS(name):
  336.     Bladex.SetTriggerSectorFunc(name, 'OnEnter', EntraQuema)
  337.     Bladex.SetTriggerSectorFunc(name, 'OnLeave', SaleQuema)
  338.  
  339.  
  340. def FireOnS(sec):
  341.     sec.OnEnter = EntraQuema
  342.     sec.OnLeave = SaleQuema
  343.  
  344.  
  345. def EntraPincha(triggername, entityname):
  346.     import Scorer
  347.     ent = Bladex.GetEntity(entityname)
  348.     if ent.Person:
  349.         if entityname == 'Player1':
  350.             Bladex.GetEntity('Camera').TType = 0
  351.             AuxFuncs.FadeTo(1.0, 60.0, 32, 0, 0)
  352.             Scorer.SetVisible(0)
  353.         
  354.         Bladex.AddScheduledFunc(Bladex.GetTime() + 0.5, MuereDeVerdadPincha, (ent,))
  355.         p = ent.Position
  356.     
  357.  
  358.  
  359. def MuereDeVerdadPincha(ent):
  360.     ent.Life = 0
  361.     ent.Wuea = Reference.WUEA_ENDED
  362.     ent.SetTmpAnmFlags(1, 1, 1, 0, 5, 1, 0)
  363.     ent.LaunchAnmType('dth_rock')
  364.  
  365.  
  366. def NailOnGS(name):
  367.     Bladex.SetTriggerSectorFunc(name, 'OnEnter', EntraPincha)
  368.  
  369.  
  370. def NailOnS(sec):
  371.     sec.OnEnter = EntraPincha
  372.  
  373.  
  374. class E_GroupAux:
  375.     ObjId = -1
  376.     
  377.     def __init__(self):
  378.         self.ObjId = ObjStore.GetNewId()
  379.         ObjStore.ObjectsStore[self.ObjId] = self
  380.  
  381.     
  382.     def __del__(self):
  383.         del ObjStore.ObjectsStore[self.ObjId]
  384.  
  385.     
  386.     def persistent_id(self):
  387.         return self.ObjId
  388.  
  389.     
  390.     def __getitem__(self, key):
  391.         return self.__dict__[key]
  392.  
  393.     
  394.     def __setitem__(self, key, value):
  395.         self.__dict__[key] = value
  396.  
  397.     
  398.     def __getstate__(self):
  399.         return (1, self.ObjId)
  400.  
  401.     
  402.     def __setstate__(self, parm):
  403.         if parm[0] == 1:
  404.             self.ObjId = parm[1]
  405.             ObjStore.ObjectsStore[self.ObjId] = self
  406.         
  407.  
  408.  
  409.  
  410. class E_Grup:
  411.     ObjId = 0
  412.     n = 0
  413.     OnDeath = None
  414.     Guys = []
  415.     ImDeadFuncs = None
  416.     
  417.     def __init__(self):
  418.         self.ObjId = ObjStore.GetNewId()
  419.         self.n = 0
  420.         self.OnDeath = None
  421.         self.Guys = []
  422.         self.ImDeadFuncs = E_GroupAux()
  423.         ObjStore.ObjectsStore[self.ObjId] = self
  424.  
  425.     
  426.     def __del__(self):
  427.         del ObjStore.ObjectsStore[self.ObjId]
  428.  
  429.     
  430.     def persistent_id(self):
  431.         return self.ObjId
  432.  
  433.     
  434.     def ImDeadFunc(self, Name):
  435.         self.ImDeadFuncs['Ch_' + Name](Name)
  436.         self.n = self.n - 1
  437.         self.Guys.remove(Name)
  438.         if self.n == 0:
  439.             if self.OnDeath:
  440.                 self.OnDeath()
  441.             
  442.         
  443.  
  444.     
  445.     def AddGuy(self, Name):
  446.         e = Bladex.GetEntity(Name)
  447.         self.ImDeadFuncs['Ch_' + Name] = e.ImDeadFunc
  448.         e.ImDeadFunc = self.ImDeadFunc
  449.         self.n = self.n + 1
  450.         if Name in self.Guys:
  451.             print 'E_Grup error : ' + Name + ' is allready here.'
  452.         else:
  453.             self.Guys.append(Name)
  454.  
  455.     
  456.     def HideBadGuys(self):
  457.         for Name in self.Guys:
  458.             HideBadGuy(Name)
  459.         
  460.  
  461.     
  462.     def UnhideBadGuys(self, number):
  463.         counter = 0
  464.         for Name in self.Guys:
  465.             counter = counter + 1
  466.             UnhideBadGuy(Name)
  467.         
  468.         return counter
  469.  
  470.     
  471.     def __getstate__(self):
  472.         ImDeadFuncsAux = []
  473.         for i in self.ImDeadFuncs.__dict__.keys():
  474.             pass
  475.         
  476.         return (1, self.ObjId, self.ImDeadFuncs, self.n, GameStateAux.SaveFunctionAux(self.OnDeath), self.Guys, ImDeadFuncsAux)
  477.  
  478.     
  479.     def __setstate__(self, parm):
  480.         if parm[0] == 1:
  481.             self.ObjId = parm[1]
  482.             ObjStore.ObjectsStore[self.ObjId] = self
  483.             self.ImDeadFuncs = parm[2]
  484.             self.n = parm[3]
  485.             GameStateAux.LoadFunctionAux(parm[4], self, 'OnDeath')
  486.             self.Guys = parm[5]
  487.             ImDeadFuncsAux = parm[6]
  488.             for i in ImDeadFuncsAux:
  489.                 GameStateAux.LoadFunctionAux(i[1], self.ImDeadFuncs, i[0])
  490.             
  491.         else:
  492.             print 'Door.__setstate__() -> Version mismatch'
  493.             self.ObjId = ObjStore.GetNewId()
  494.             ObjStore.ObjectsStore[self.ObjId] = self
  495.             self.n = 0
  496.             self.OnDeath = None
  497.             self.Guys = []
  498.             self.ImDeadFuncs = E_GroupAux()
  499.  
  500.  
  501. PersonasEnLlamas = []
  502.  
  503. def EnciendeEnLlamas(o, Intensity = 15, Precission = 0.1):
  504.     if not (o.Kind in PersonasEnLlamas):
  505.         PersonasEnLlamas.append(o.Kind)
  506.         Bladex.AddCombustionDataFor(o.Kind, 'Fire', 250, 400, 4, 1, 3, 144000)
  507.     
  508.     o.SelfIlum = 0.0
  509.     o.CatchOnFire(0, 0, 0)
  510.     luz = Bladex.CreateEntity(o.Name + 'Luz', 'Entity Spot', 0, 0, 0)
  511.     luz.Color = (200, 100, 0)
  512.     luz.Intensity = Intensity
  513.     luz.Precission = Precission
  514.     luz.CastShadows = 0
  515.     luz.Visible = 1
  516.     luz.SizeFactor = 0
  517.     o.Link(luz)
  518.  
  519.  
  520. def ObjAlpha(o, alpha = 0.8, SelfIlum = 0.0):
  521.     o.Alpha = alpha
  522.     o.RasterMode = 'AdditiveAlpha'
  523.     o.RasterMode = 'Read'
  524.     o.CastShadows = 0
  525.     o.SelfIlum = SelfIlum
  526.  
  527.  
  528. def ValidAppear(pos, func = None, param = None):
  529.     entid = Bladex.GetEntitiesAt(pos[0], pos[1], pos[2], 4000)
  530.     for on in entid:
  531.         o = Bladex.GetEntity(on)
  532.         if o.Person:
  533.             if o.Life > 0:
  534.                 if o.Alpha > 0.01:
  535.                     print 'Trying to do it, but', on, 'is bothering. Next try in 5 seconds.'
  536.                     if func:
  537.                         Bladex.AddScheduledFunc(Bladex.GetTime() + 5.0, ValidAppear, (pos, func, param))
  538.                     
  539.                     return 0
  540.                 
  541.             
  542.         
  543.     
  544.     if func:
  545.         apply(func, param)
  546.         print 'The function was XQted'
  547.     else:
  548.         return 1
  549.  
  550.  
  551. def CreateFalseCube(pos, timeToKill = -1, Name = ''):
  552.     o = Bladex.CreateEntity(Name + 'quad', 'Bloque', pos[0], pos[1] - 1500, pos[2])
  553.     o.Orientation = (0.707107245922, 0.0, 0.0, 0.707106292248)
  554.     o.Scale = 4
  555.     o.CastShadows = 0
  556.     o.Alpha = 0.0
  557.     o.RasterMode = 'Read'
  558.     if timeToKill != -1:
  559.         Bladex.AddScheduledFunc(Bladex.GetTime() + timeToKill, o.SubscribeToList, ('Pin',))
  560.     
  561.     return o
  562.  
  563.  
  564. def CleanArea(x, y, z, radius):
  565.     list = Bladex.GetEntitiesAt(x, y, z, radius)
  566.     enCounter = 0
  567.     for name in list:
  568.         o = Bladex.GetEntity(name)
  569.     
  570.     return enCounter
  571.  
  572.  
  573. def EnterSecEvent(x, y, z, func):
  574.     sec = Bladex.GetSector(x, y, z)
  575.     EnterSecEventSector(sec, func)
  576.  
  577.  
  578. def GetSectorIdx(pos):
  579.     if type(pos) != types.TupleType:
  580.         return pos
  581.     else:
  582.         return Bladex.GetSector(pos[0], pos[1], pos[2]).Index
  583.  
  584.  
  585. def EnterSecIdEvent(id, func):
  586.     if type(id) == types.StringType:
  587.         EnterTSEvent(id, func)
  588.         return id
  589.     elif type(id) == types.TupleType:
  590.         sec = Bladex.GetSector(id[0], id[1], id[2])
  591.         EnterSecEventSector(sec, func)
  592.         return sec.Index
  593.     else:
  594.         sec = Bladex.GetSector(id)
  595.         EnterSecEventSector(sec, func)
  596.         return id
  597.  
  598.  
  599. def EnterSecEventSector(sec, func):
  600.     if sec:
  601.         if not SectorTable.has_key(sec.Index):
  602.             if sec.OnEnter:
  603.                 print 'ERROR : OnEnter Asigned to', sec.OnEnter
  604.             else:
  605.                 SectorTable[sec.Index] = []
  606.         else:
  607.             numerox = len(SectorTable[sec.Index])
  608.             if numerox > 0:
  609.                 if Reference.PYTHON_DEBUG >= 2:
  610.                     print 'Warning : OnEnter have', numerox, 'functions'
  611.                 
  612.             
  613.         SectorTable[sec.Index].insert(0, func)
  614.         sec.OnEnter = OnPlayerEnter
  615.         return sec.Index
  616.     else:
  617.         print 'ERROR : Sector invalid!'
  618.  
  619.  
  620. def OnPlayerEnter(sectorindex, entityname):
  621.     pass
  622.  
  623. SectorTable = { }
  624.  
  625. def EnterTSEvent(secname, func):
  626.     if secname:
  627.         if not SectorTable.has_key(secname):
  628.             if Bladex.GetTriggerSectorFunc(secname, 'OnEnter'):
  629.                 print 'ERROR : OnEnter Asigned to ', secname
  630.             else:
  631.                 SectorTable[secname] = []
  632.         else:
  633.             numerox = len(SectorTable[secname])
  634.             if numerox > 0:
  635.                 if Reference.PYTHON_DEBUG >= 2:
  636.                     print 'Warning : OnEnter have', numerox, 'functions'
  637.                 
  638.             
  639.         SectorTable[secname].insert(0, func)
  640.         Bladex.SetTriggerSectorFunc(secname, 'OnEnter', OnPlayerEnter)
  641.         return secname
  642.     else:
  643.         print "ERROR : Sector '" + secname + "' invalid!"
  644.  
  645.  
  646. def LuzChapuzera(light, FinishTime, delta = 1):
  647.     t = Bladex.GetTime()
  648.     light.Move(0, 0, delta)
  649.     if t < FinishTime:
  650.         Bladex.AddScheduledFunc(t + 0.0, LuzChapuzera, (light, FinishTime, -delta))
  651.     
  652.  
  653.  
  654. def SaveData(filename):
  655.     import cPickle
  656.     funcfile = open(filename, 'wt')
  657.     p = cPickle.Pickler(funcfile)
  658.     d = (muertonum, ActualLevel, QuakeFactor, FIRE_DAMAGE, PersonasEnLlamas, SectorTable)
  659.     p.dump(d)
  660.     funcfile.close()
  661.  
  662.  
  663. def LoadData(filename):
  664.     global muertonum, ActualLevel, QuakeFactor, FIRE_DAMAGE, PersonasEnLlamas, SectorTable
  665.     import cPickle
  666.     funcfile = open(filename, 'rt')
  667.     p = cPickle.Unpickler(funcfile)
  668.     d = p.load()
  669.     funcfile.close()
  670.     print d
  671.     muertonum = d[0]
  672.     ActualLevel = d[1]
  673.     QuakeFactor = d[2]
  674.     FIRE_DAMAGE = d[3]
  675.     PersonasEnLlamas = d[4]
  676.     SectorTable = d[5]
  677.  
  678. import GameState
  679. GameState.ModulesToBeSaved.append(__import__(__name__))
  680.